/**
 * Project Name:springBoot-controller
 * File Name:FtpController.java
 * Package Name:com.libra.io.controller
 * Date:2018年11月6日下午4:07:38
 * Copyright (c) 2018, wangzhch All Rights Reserved.
 *
*/

package com.libra.io.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.libra.model.vo.ResponseData;
import com.libra.service.FtpService;

/**
 * ClassName:FTP文件上传和下载 <br/>
 * Date:     2018年11月6日 下午4:07:38 <br/>
 * @author   wangzhch
 * @version  
 * @since    JDK 1.8
 * @see 	 
 */
@RestController
@RequestMapping("ftp")
public class FtpController {

	private Logger log = LoggerFactory.getLogger(FtpController.class);
	
	@Autowired
	private FtpService ftpService;
	/**
	 * 
	 * uploadFtp:(将一段内容生成txt文档,再上传到ftp). <br/>
	 * @author wangzhch
	 * @param context
	 * @return
	 * @since JDK 1.8
	 */
	@RequestMapping(value="/uploadFtp")
	public ResponseData uploadFtp(@RequestBody String context) {
		log.info("ftp上传文件内容:{}",context);
		ResponseData data = ftpService.uploadFtp(context);
		log.info("ftp上传响应结果：{}",data);
		return data;
	}
	
	/**
	 * 
	 * downLoadFtp:(ftp文件下载). <br/>
	 * @author wangzhch
	 * @return
	 * @since JDK 1.8
	 */
	@RequestMapping(value="/downLoadFtp")
	public ResponseData downLoadFtp(@RequestBody String downName) {
		log.info("ftp下载{}文件",downName);
		ResponseData data = ftpService.downLoadFtp(downName);
		log.info("ftp下载响应结果：{}",data);
		return data;
	}
}

